package cn.kgc.spring.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * @author: mosin
 * @version: v1.0  2022/10/13
 * 环绕通知
 */
public class Around implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {

        try {
            System.out.println("----------前置通知------------");
            // 标识执行核心业务代码
            Object proceed = invocation.proceed();

            System.out.println("----------后置通知------------");
            return proceed;
        } catch (Throwable throwable) {
            System.out.println("----------异常通知------------");
            throwable.printStackTrace();
        }finally {
            System.out.println("----------最终通知------------");
        }
        return null;
    }
}
